Conversation
Lyrics following music via \addlyrics were appended as plain lists directly into the barlist of the current part, so iterating the part crashed with "AttributeError: 'list' object has no attribute 'pickup'". Collect \addlyrics into a LyricsSection and merge it into the preceding music when it ends, as is already done for \lyricsto. This also makes the lyrics appear in the exported MusicXML. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A \new Voice placed directly in a StaffGroup (or other group) has an implicit Staff in LilyPond, but the MusicXML export never created a part for it. Its music was dropped, and a \set Staff.instrumentName inside it failed with "'NoneType' object has no attribute 'name'". When a Voice context starts with no part open, create a new part and add the voice to it when the Voice ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LilyPond creates a Staff for a Voice that is not inside one. The export put such voices in no part (an empty score), in the part of the staff before them, or in one part together. Since errors in node handlers are no longer hidden, a \set Staff.instrumentName in such a voice even raised an AttributeError. Now a Voice that starts while no part is open gets a part, and its music is added to that part when the Voice ends. Sections added to a part stay findable by name, so \lyricsto still finds the voice. A top-level music expression without \score (e.g. \new Staff << ... >>) is now handled itself, not only its children, so the voices in it are recognized as being inside a Staff. The test input with a StaffGroup of voices is from frescobaldi#197, which addresses the same problem. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CMyxTwm2w6VtbxBdt5dL1T
|
Hi @wattdave, I noticed it overlaps with a stack of MusicXML export PRs I opened (#199 → #202 → #200 → #201), and wanted to flag it so we don't duplicate work. This PR (#197): #202 now also gives a
#196: #201 implements I'm happy to go either way:
Whatever is easier for you and the maintainers. |
Builds on the
\addlyricsfix (#196). This PR is based on that branch, so it also contains that commit; please review #196 first.Problem
A
\new Voiceplaced directly in a group has an implicit Staff in LilyPond:ly musicxmlexports no parts at all for this. In a real four-voice CPDL score,where the Voices use note variables and
\set Staff.instrumentName, it alsoprints
'NoneType' object has no attribute 'name'.Root cause
In
ParseSource.check_context()(ly/musicxml/lymus2musxml.py), theVoicebranch only opens a new section. No part is created unless a
Staffcontextdoes it. Because nothing ever adds the section to a part, the music is dropped,
and
Mediator.set_partname()writes toself.part, which isNone.Fix
When a
Voicecontext starts with no part open, create one withmediator.new_part(). When that Voice ends, add its music to the part withmediator.check_part(), the same way a Staff is handled. A newimplicit_staffstack tracks this for nested Voices.
Tests
tests/test_xml_files/voice_in_group.{ly,xml}andtest_voice_in_group.the full suite gives 20 passed and 2 xfailed. The 2 xfails were already there.
output went from an empty document to 4 parts with notes and lyrics.
Not addressed
LayoutContextandKeywordwarnings: the handlers for\layout/\midiblocks are not implemented. These warnings are harmless.
\cadenzaOn, and bar checks used where there are nobarlines, still produce measures of the wrong length.
🤖 Generated with Claude Code